package com.weizengquan.ereader.book;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.FileInputStream;

import com.weizengquan.ereader.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;

public class ShowBookContentsActivity extends Activity implements OnClickListener{
	private String fileName="b.txt";
	EditText editText;

	/** Called when the activity is first created. */
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
        
        EditText editText=(EditText)findViewById(R.id.editText1);
    	editText.setOnClickListener(this);  
    	
		fileName=getIntent().getStringExtra("filename");
    		try{
    			    //FileReader fr = new FileReader(in);
    			    InputStreamReader in=new InputStreamReader(new FileInputStream(fileName), "GBK"); 
        			BufferedReader reader=new BufferedReader(in);
        			String s;
        			StringBuilder buf=new StringBuilder();
        			while((s=reader.readLine())!=null){

        				buf.append(s+"\n");
        			}
        			in.close();
        			
        			editText.setText(buf.toString());

    		}catch(Throwable t){
    			Toast
    				.makeText(this, "Execption:"+t.toString(), Toast.LENGTH_LONG)
    				.show();
    		}
    }
    


    private void FileInputStream() {
		// TODO Auto-generated method stub
		
	}



	public void onClick(View v){
    	//switch(v.getId()) {
    	//case R.id.new_button:
    		//editText.setText(null);

    		//break;
    		
    	//}
    }
    

}
